package com.javaoopfour;

import com.javaoopfour.util.PageUtil;
import com.javaoopfour.util.StrUtil;

import java.util.Scanner;

public class DemoTst1 {
    public static void main(String[] args) {
        boolean isOk=true;
        PageUtil pageUtil =new PageUtil();


        Menus menu = new Menus();
        Menus[] menus = new Menus[10];

        Menus[] menus1 =   menu.initMenu(menus);


        Menus[] menus2 = pageUtil.nextPage(pageUtil.getPageCuree(), pageUtil.getLimit(), menus1);
        for (int i = 0; i <menus2.length ; i++) {
            if(menus2[i] !=null){
                System.out.println(menus2[i].mName);
            }
        }
       do {

           System.out.println("1:上一页\t\t\t\t\t\t2:下一页\t\t\t3：退出");
           System.out.println("请输入您需要的选择：");
           Scanner scanner = new Scanner(System.in);
           int i = scanner.nextInt();
           switch (i){
               case 1:   pageUtil.setPageCuree(pageUtil.getPageCuree()-1);

                   Menus[] menus4 = pageUtil.nextPage(pageUtil.getPageCuree(), pageUtil.getLimit(), menus1);
                   for (int j = 0; j <menus4.length ; j++) {
                       if(menus4[j] !=null){
                           System.out.println(menus4[j].mName);
                       }
                   }
                   break;
               case 2:
                   //改变页码
                   pageUtil.setPageCuree(pageUtil.getPageCuree()+1);

                   Menus[] menus3 = pageUtil.nextPage(pageUtil.getPageCuree(), pageUtil.getLimit(), menus1);
                   for (int j = 0; j <menus3.length ; j++) {
                       if(menus3[j] !=null){
                           System.out.println(menus3[j].mName);
                       }
                   }
                   break;
               default:
                   System.exit(1);
           }
       }while (isOk);
    }
}
